package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 移动端预约控制器
 */
@Slf4j
@RestController
@RequestMapping("/mobile/setmeal")
public class MobileSetmealController {
    @Autowired
    private SetMealService setMealService;
    /**
     *  套餐查询所有
     * @return
     */
    @GetMapping("/getSetmeal")
    public Result setmealFindAll(){
        List<Setmeal> setmealList = setMealService.findAll();
        return new Result(true, MessageConst.QUERY_SETMEALLIST_SUCCESS,setmealList);
    }

    /**
     * 根据id查询套餐详情
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Integer id){
            try{
                Setmeal setmeal = setMealService.findById(id);
                return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
            }catch (Exception e){
                e.printStackTrace();
                return new Result(false,MessageConst.QUERY_SETMEAL_FAIL);
            }
    }

}
